/*
 * @Author: 胡晓星
 * @Date: 2024-09-04 17:46:25
 * @LastEditors: 491256909@qq.com
 * @LastEditTime: 2025-08-12 17:25:08
 * @FilePath: -serve\src\modules\player\player.controller.ts
 * @Description: 
 */
import {
  Body,
  Controller,
  Query,
  Param,
  Request,
  UseGuards,
  Get,
  Post,
  Delete,
  Patch,
} from '@nestjs/common';
import { PlayerService } from './player.service';
import {
  GetPlayersDto,
  GetTeamsDto,
  CreateTeamDto,
  UpdateTeamDto,
  CreatePlayerDto,
  UpdatePlayerDto,
} from './dto';
@Controller('player')
export class PlayerController {
  constructor(private readonly playerService: PlayerService) {}
  /*************    球员列表    *************/
  @Get('getAllPlayers')
  getAllPlayers(@Query() queryDto: GetPlayersDto) {
    return this.playerService.findAll(queryDto);
  }

  @Post('addPlayer')
  addPlayer(@Body() player: CreatePlayerDto) {
    return this.playerService.createPlayer(player);
  }

  @Patch('updatePlayer/:id')
  updatePlayer(@Param('id') id: number, @Body() player: UpdatePlayerDto) {
    return this.playerService.updatePlayer(id, player);
  }

  /*************    球队列表    *************/
  @Get('getAllTeams')
  getAllTeams(@Query() queryDto: GetTeamsDto) {
    return this.playerService.findAllTeams(queryDto);
  }

  //   @Get('addTeam')
  @Post('addTeam')
  addTeam(@Body() team: CreateTeamDto) {
    return this.playerService.createTeam(team);
  }

  @Delete('removeTeam/:id')
  //   @UseGuards(PreviewGuard)
  removeTeam(@Param('id') id: number) {
    return this.playerService.removeTeam(id);
  }

  @Patch('updateTeam/:id')
  updateTeam(@Param('id') id: number, @Body() team: UpdateTeamDto) {
    return this.playerService.updateTeam(id, team);
  }

  //   @Post('getPlayerById')
  //   getPlayerById(@Query() queryDto: GetTeamsDto) {
  //       return this.playerService.findOne({
  //         where: { id },
  //       });
  //   }
}

